Skip to content

Add experimental PW LOBPCG eigensolver#7406

Open
amadeus725 wants to merge 4 commits into
deepmodeling:developfrom
amadeus725:feature/pw-lobpcg
Open

Add experimental PW LOBPCG eigensolver#7406
amadeus725 wants to merge 4 commits into
deepmodeling:developfrom
amadeus725:feature/pw-lobpcg

Conversation

@amadeus725
Copy link
Copy Markdown

Background

During recent code reading and testing, we found that the current PW bpcg
solver path does not appear to expose an explicit generalized eigenproblem
interface for the overlap matrix S. Further comparison on USPP cases showed
that bpcg can produce results noticeably different from cg and dav, where
generalized eigenproblem handling is required.

As a first step toward improving this area, this PR introduces an experimental
LOBPCG solver framework for PW standard eigenproblems.

Changes

  • Add DiagoLobpcg for CPU PW standard eigenproblems (S = I).
  • Add ks_solver = lobpcg support in the PW hsolver path.
  • Add input documentation for lobpcg.
  • Add SCF iteration print label LB.
  • Add unit tests for:
    • Hermitian eigenvalue correctness
    • orthonormality and residual checks
    • generalized-interface not-implemented behavior

Current Limitations

This PR intentionally does not claim USPP/generalized eigenproblem support yet.

Currently supported:

  • PW basis
  • CPU
  • std::complex<double>
  • norm-conserving / standard eigenproblem path (S = I)

Currently not supported:

  • USPP / generalized eigenproblem (S != I)
  • GPU
  • float instantiation
  • band-parallel LOBPCG

Unsupported generalized usage exits explicitly with WARNING_QUIT.

Tests

  • cmake --build . --target hsolver MODULE_HSOLVER_lobpcg abacus_basic_para -j2
  • env I_MPI_FABRICS=shm ctest -R MODULE_HSOLVER_lobpcg --output-on-failure
  • git diff --check

Copilot AI review requested due to automatic review settings May 30, 2026 13:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mohanchen
Copy link
Copy Markdown
Collaborator

Nice try. You can keep refining the implementation and use test cases to verify its correctness and performance.

Comment thread source/source_hsolver/diago_lobpcg.h Outdated
Real* eigenvalue_in,
const std::vector<double>& ethr_band);

/// USPP (S≠I) diagonalization. NOT IMPLEMENTED — aborts.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually standard eigenproblem is just a special case(S=I) for generalized problem. Only one diag interface is necessary for both, and the latter is adequate.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I will narrow down the interface.

Comment thread source/source_hsolver/diago_lobpcg.h Outdated
Real* eigenvalue_in,
const std::vector<double>& ethr_band);

/// USPP (S≠I) diagonalization. NOT IMPLEMENTED — aborts.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard eigenvalue problem is just a special case (where S is I) for the generalized problem. Thus one diag interface (the latter) is adequate.

Comment thread source/source_hsolver/diago_lobpcg.cpp Outdated
namespace hsolver {

// ============================================================================
// Band-major explicit-loop helpers (CPU, n_band_l == n_band required)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most loops can be achieved with a BLAS 3 op

@amadeus725
Copy link
Copy Markdown
Author

Updated LOBPCG to expose only the generalized diag(hpsi, spsi, ...) interface. The current implementation still only accepts S = I; non-identity overlap exits explicitly. Also replaced several explicit dense matrix operations with existing PGemmCN / PLinearTransform helpers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants